package com.xiaofu.normal;

import com.rabbitmq.client.Channel;
import com.xiaofu.utils.ConnectUtil;

import java.nio.charset.StandardCharsets;

/**
 * @author luofuzhou
 * @date 2024/11/19
 * @dec 描述
 */
public class RabbitProducer {
    private final static String QUEUE_NAME = "xiaofu";

    public static void main(String[] args) throws Exception {
        Channel channel = ConnectUtil.getChannel();
        channel.queueDeclare(QUEUE_NAME, false, false, false, null);
        for (int i = 0; i < 10; i++) {
            channel.basicPublish("", QUEUE_NAME, null, ("hello rabbitmq" + i).getBytes(StandardCharsets.UTF_8));
        }
        System.out.println("消息发送完毕");
        channel.close();
    }
}
